package com.celesea.configuration.log;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.DispatcherType;

@Configuration
public class LogConfiguration {
    @Bean
    public FilterRegistrationBean setLogFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setDispatcherTypes(DispatcherType.REQUEST);
        registration.setFilter(new LogFilter());
        registration.addInitParameter(ExcludableFilter.PARAM_NAME_EXCLUSIONS,
                "*.js,*.gif,*.jpg,*.png,*.css,*.ico");
        registration.setOrder(Integer.MAX_VALUE);
        return registration;
    }
}
